/**
 * @author 江黎
 * @date 2021/11/20 21:09
 * init()和cliinit()的执行顺序
 */
public class T {
    public static int k = 0;
    public static T t1 = new T("t1");
    public static T t2 = new T("t2");
    public static int i = print("i");
    public static int n = 99;

    static {
        print("静态块");
    }

    public int j = print("j");

    {
        print("普通代码块");
    }

    public T(String str) {
        System.out.println((++k) + ":" + str + " i=" + i + " n=" + n);
        ++n;
        ++i;
    }

    public static int print(String str) {
        System.out.println((++k) + ":" + str + " i=" + i + " n=" + n);
        ++n;
        return ++i;
    }

    public static void main(String[] args) {
        // 执行main()方法，main()所在的类就会初始化，即执行<clinit>()方法
        // public static T t1 = new T("t1"); 会在<clinit>()方法调用，new T()被调用
        // 构造方法的执行是在<init>()方法里面，构造方法执行之前会执行普通变量显示赋值和普代码块
    }
}